
import aima.search.framework.HeuristicFunction;
import java.util.ArrayList;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Marc
 */
public class CarsHeuristicFunction implements HeuristicFunction {

    public int getHeuristicValue(Object state) {
        State CarsState= (State)state;
        int sum = 0;
        int extraDistance = 0;
        int n = CarsState.getNDrivers();
        for (int i = 0; i < n; ++i){
            int distanceCar = CarsState.getDistanceDriver(i);
            if (distanceCar > 300) extraDistance += distanceCar - 300;
            sum += distanceCar;
        }
        sum += 2000*extraDistance;
        //sum = 0-sum;
        //sum = Integer.MAX_VALUE-sum;
        //System.out.println(" => Heur " + sum);
        System.out.println(" => conductors " + CarsState.getNDrivers() + " fh: " + sum + "distancia extra: " + extraDistance);
        return sum;
    }
}
